<?php

/**
 * 转盘
 * */

namespace App\Http\Controllers;

use App\Http\Services\RoomImageCheckService;
use App\Http\Services\RoomMsgServices;


class RoomImageCheckController extends BaseController
{
    protected $roomImageCheckService;
    protected $roomMsgService;
    public function __construct()
    {
        $this->roomImageCheckService = new RoomImageCheckService();
        $this->roomMsgService = new RoomMsgServices();
    }

    /**
     * 设置上传图片的地址
     * */
    public function setImgUrl()
    {
        do {
            if (!$this->checkRequest()) {
                break;
            }

            $this->callCommon($this->roomImageCheckService, 'setImgUrl', $this->requestData);

        } while (false);

        $this->responseData();
    }

    /**
     * 获取已审核图片列表
     */
    public function getImgList()
    {
        do {
            if (!$this->checkRequest()) {
                break;
            }

            $this->callCommon($this->roomImageCheckService, 'getImgList', $this->requestData);

        } while (false);

        $this->responseData();
    }

    /**
     * 删除图片
     */
    public function delImg()
    {
        do {
            if (!$this->checkRequest()) {
                break;
            }

            $this->callCommon($this->roomImageCheckService, 'delImg', $this->requestData);

        } while (false);

        $this->responseData();
    }

    /**
     * 发送图片消息
     */
    public function sendImgMsg(){
        do {
            if (!$this->checkRequest()) {
                break;
            }

            $res = $this->callCommon($this->roomImageCheckService, 'sendImgMsg', $this->requestData ,false);
            if($res['code'] == 0 && !empty($res['data']['image'])){
              $this->roomMsgService->sendImgMsg($this->requestData['room_id'] ,$this->requestData['user_id'] ,$res['data']['image']);
            }

        } while (false);

        $this->responseData();
    }
}
